package com.test.demo.controller;


import com.test.demo.model.Grante;
import com.test.demo.service.GranteService;
import com.test.demo.tool.ResponseMessage;
import com.test.demo.tool.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController(value = "/Grante")
public class GranteController {
    /**
     *范琳
     * 借款信息表
     */
    @Autowired
    private GranteService granteservice;

    @RequestMapping(value = "/getStr1")
    public String getStr1(String str) {
        return "你输入的名字叫：" + str;
    }
    @CrossOrigin
    @RequestMapping(value = "/getOneg")
    public Grante getOneg(Integer gid) {
        return granteservice.selectByPrimaryKeygra(gid);
    }
    @CrossOrigin
    @RequestMapping(value = "getGid")
    public List<Grante> getGid(){
        System.out.println("调用角色全部类型的接口");
        List<Grante> listGrante =granteservice.getGid();
        return listGrante;
    }
    @CrossOrigin
    @RequestMapping(value="/getAllg")
    public ResponseMessage getAllg(){
        System.out.println("调用角色全部信息的方法");
        Map<String,List> map = new HashMap<>();
        map.put("list",granteservice.getAllg());
        return Result.success("200",map);
    }
    @CrossOrigin
    @RequestMapping(value = "/delGrante",method = RequestMethod.GET)
    public int delGrante(Integer gid){
        return granteservice.delGrante(gid);
    }
    @CrossOrigin
    @RequestMapping(value = "/addGrante",method = RequestMethod.PUT)
    public int addGrante(@RequestBody Grante grantemodel){
        //判断传入参数是否为空
        if (grantemodel!=null){

        }else {

        }
        return granteservice.insertGrante(grantemodel);
    }
    //更新数据
    @CrossOrigin
    @RequestMapping(value = "/updateGrante",method = RequestMethod.PUT)
    public int updateGrante(@RequestBody Grante grantemodel){
        return granteservice.updateGrante(grantemodel);
    }
}
